package TextOne;

import java.util.Scanner;

/**
 * @author zjjcl
 */
public class User {
    String username;
    String keyword;

    public User(String username,String keyword){
        this.username=username;
        this.keyword=keyword;
    }
    public static boolean checkName(String userna){
        String regExp="^[a-zA-Z][a-zA-Z0-9]{5,9}$";
        return userna.matches(regExp);
    }
    public  static boolean checkPwd(String keywor){
        String regExp="^[0-9]{6}$";
        if (keywor.matches(regExp)) {
            return true;
        } else {
            return false;
        }
    }
    public static void main(String[] agrs){

        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username=scanner.nextLine();
        System.out.println("请输入密码：");
        String keybord=scanner.nextLine();
        int flag=1;
        while (!checkName(username)){
            System.out.println("用户名不合法");
            flag=0;
            break;
        }
        while (!checkPwd(keybord)){
            System.out.println("密码不合法");
            flag=0;
            break;
        }
        if (flag==1) {
            System.out.println("合法");
        }
    }
}
